Skip to content

fix: eradicate flaky e2e test patterns across all spec files#23

Merged
willchan merged 2 commits intomainfrom
claude/fix-flaky-e2e-tests-7cwIQ
Mar 8, 2026
Merged

fix: eradicate flaky e2e test patterns across all spec files#23
willchan merged 2 commits intomainfrom
claude/fix-flaky-e2e-tests-7cwIQ

Conversation

@willchan
Copy link
Owner

@willchan willchan commented Mar 8, 2026

Replace three root causes of test flakiness with deterministic alternatives:

  1. Replace try/catch timer skip pattern with deterministic loop - the rest
    timer always appears between sets (never after the last), so we can
    handle it without try/catch and arbitrary 1s timeouts. Extract shared
    completeAllSets() and completeRemainingSets() helpers.

  2. Replace all waitForTimeout() calls with proper Playwright assertions
    that wait for specific UI state changes (element visibility, text
    content, CSS class changes) instead of arbitrary delays.

  3. Replace waitForSelector('#rest-timer:not(.hidden)') CSS hacks with
    Playwright's built-in toBeVisible() assertions.

Also remove CI retry (retries: 1) from playwright.config.ts since tests
should now be deterministic without needing retries as a safety net.

https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R

claude added 2 commits March 8, 2026 17:48
Replace three root causes of test flakiness with deterministic alternatives:

1. Replace try/catch timer skip pattern with deterministic loop - the rest
   timer always appears between sets (never after the last), so we can
   handle it without try/catch and arbitrary 1s timeouts. Extract shared
   completeAllSets() and completeRemainingSets() helpers.

2. Replace all waitForTimeout() calls with proper Playwright assertions
   that wait for specific UI state changes (element visibility, text
   content, CSS class changes) instead of arbitrary delays.

3. Replace waitForSelector('#rest-timer:not(.hidden)') CSS hacks with
   Playwright's built-in toBeVisible() assertions.

Also remove CI retry (retries: 1) from playwright.config.ts since tests
should now be deterministic without needing retries as a safety net.

https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R
The PWA export/import test was racing with the app's seedDefaults()
initialization. waitForSelector('#app') resolves immediately since #app
is a static HTML element, but seedDefaults() is async and may still be
writing exercises to IndexedDB. If exportAll() runs before seedDefaults
finishes, the original snapshot has fewer exercises than the restored
one, causing the roundtrip comparison to fail.

Fix: wait for #start-workout-btn which only renders after seedDefaults()
and startRouter() complete, proving the app is fully initialized.

https://claude.ai/code/session_017FCubTmucERSuDiZi49Z4R
@willchan willchan merged commit a1838e5 into main Mar 8, 2026
1 check passed
@willchan willchan deleted the claude/fix-flaky-e2e-tests-7cwIQ branch March 8, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants